#!/bin/bash
HERE=`pwd`
#----------------------------------------------------------
if [ $# != 1 ]; then
  echo Give cloonix to install as param
  exit
fi
#----------------------------------------------------------
CLOONIX=$1
if [ ! -e $CLOONIX ]; then
  echo NOT FOUND:
  echo $CLOONIX
  exit
fi
#----------------------------------------------------------
for i in cloonix_dta cloonix_mon cloonix_osh cloonix_xwy \
         cloonix_cli cloonix_gui cloonix_net cloonix_scp \
         cloonix_zor cloonix_ctl cloonix_ice cloonix_ocp \
         cloonix_ssh; do 
  rm -f /usr/local/bin/${i}
done
rm -rf /usr/local/bin/cloonix
mkdir -p /usr/local/bin
cd /usr/local/bin
tar zxvf ${HERE}/${CLOONIX}
chown -R root:root /usr/local/bin/cloonix*
MUTAP=/usr/local/bin/cloonix/server/muswitch/mutap/cloonix_mutap
chmod u+s ${MUTAP}
MUOVS=/usr/local/bin/cloonix/server/muswitch/muovs/cloonix_muovs
chmod u+s ${MUOVS}
USBHELP=/usr/local/bin/cloonix/common/spice
USBHELP+=/spice_lib/spice-client-glib-usb-acl-helper
if [ -e ${USBHELP} ]; then
  chmod u+s ${USBHELP}
fi
#----------------------------------------------------------
rm -f ${HERE}/${CLOONIX}
#----------------------------------------------------------
